package com.bdc.whatwhat.utils;

/**
 * Created by dev-w8-gfi on 25/06/2014.
 */

import com.bdc.whatwhat.receiver.AlarmManagerBroadcastReceiver;


import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Utility {

    public static String getCurrentTime(String timeformat) {
        Format formatter = new SimpleDateFormat(timeformat);
        Date d = new Date();
        return formatter.format(new Date());

    }

    public static String getCurrentTime(long date1) {
        long intervalle = date1 - AlarmManagerBroadcastReceiver.time;

        String seconds = (int) (intervalle / 1000) % 60 + "";
        String minutes = (int) ((intervalle / (1000 * 60)) % 60) + "";
        String hours = (int) ((intervalle / (1000 * 60 * 60)) % 24) + "";
        String days = (int) ((intervalle / (1000 * 60 * 60 * 24))) + "";

        if (Integer.valueOf(seconds) < 10) {
            seconds = "0" + seconds;
        }

        if (Integer.valueOf(minutes) < 10) {
            minutes = "0" + minutes;
        }

        if (Integer.valueOf(hours) < 10) {
            hours = "0" + hours;
        }


        if(Integer.valueOf(days) == 0)
        return hours + ":" + minutes + ":" + seconds;

        return  days + " jours";
    }

}